//
//  WmcCloudAllPhotoTableHeaderView.swift
//  YPWatermarkCamera
//
//  Created by 周诗松 on 2022/5/30.
//

import UIKit
import YPBedrock

class WmcCloudAllPhotoTableHeaderView: WmcBaseView {
    // Internal

    override func makeUI() {
        backgroundColor = .wmc_white_FFFFFF

        addSubview(dateLabel)
        addSubview(countLabel)

        dateLabel.snp.makeConstraints { make in
            make.left.equalTo(16)
            make.bottom.equalTo(-8)
        }

        countLabel.snp.makeConstraints { make in
            make.bottom.equalTo(dateLabel.snp.bottom).offset(-1)
            make.left.equalTo(dateLabel.snp.right)
        }
    }

    func bindModel(_ model: WmcMediaPhotoDayModel) {
        var today: String = ""
        if let date = WmcDateManager.shared.networkDate.value {
            today = date.yp.string(.ymd_cn)
        }
        WmcLogManager.Log("today: \(today), date: \(model.date)")
        if today == model.date {
            dateLabel.text = "今天"
        } else {
            dateLabel.text = model.date
        }

        countLabel.text = "/\(model.count)张照片"
    }

    // Private

    private lazy var dateLabel: UILabel = {
        let label = UILabel()
        label.textColor = .wmc_grayH2_323233
        label.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
        return label
    }()

    private lazy var countLabel: UILabel = {
        let label = UILabel()
        label.textColor = .wmc_grayH5_606066
        label.font = UIFont.systemFont(ofSize: 13)
        return label
    }()
}
